<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<title>angular/不完整版placeholder</title>
	<style>
		.app{
			position: relative;
		}
		.p{
			position: absolute;
			bottom: -6px;
			right: 950px;
		}
		textarea{
			resize: none;
		}

	</style>
</head>
<body>
	

	<div class="app" ng-app = "myApp" ng-controller="nameController">
		<!-- <direct for-na = "name"></direct> -->
		<input type="text" class="abc" ng-model="name" ng-keyup="clear()" ng-blur="nVal()" >
		
		<textarea name="" id="text" cols="30" rows="10" ng-keyup="mun()" ></textarea>			
		<p class="p"><span class="sp">0</span>/10</p>
		<!-- <span>{{name}}</span> -->
		
	<div>

	<script src="../lib/jquery.min.js"></script>
	<script src="../lib/angular.min.js" type="text/javascript"></script>
	<script>

		var app = angular.module('myApp',[]); 
	/*	app.directive("direct",function(){

	        return{

	            restrict: 'ECMA',

	            template: '<div>指令：<input type="text" value="{{ name }}" /></div>',

	            scope:{

	              name:'=forNa'

	            }
	        } 
		})*/
		app.controller("nameController",function($scope){
	        $scope.name = "大王叫我来巡山";

	        $scope.mun = function() {

	        	var text = $('#text').val().length;
	        	var sp = $('.sp');
	        	//console.log(sp)
	        	
	        	if(text > 10) {
	        		text = 10;
	        		//console.log($('#text').val())
	        		//$('#text').val().substr(0,10)
	        		//$('#text').attr('disabled','disabled');
	        		//$('#text').attr('readonly','readonly');
	        	}

	        	sp.html(text)
	        }

	        $scope.clear = function() {

	        	var val = $('.abc').val();
	        	if(val == $scope.name){
	        		$scope.name = "";
	        	}else {
	        		$scope.name = val;
	        	}

	        	/*if(val == ''){
	        		$scope.name = "大王叫我来巡山"
	        	}else {
	        		$scope.name = val;
	        	}*/
	        	
	        	
	        };

	        $scope.nVal = function() {
	        	var val = $('.abc').val();
	        	if(val == ''){
	        		$scope.name = "大王叫我来巡山"
	        	}else {
	        		$scope.name = val;
	        	}
	        	
	        }
		});

		




	</script>
</body>
</html>